package com.rs.service.impl.rs;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rs.dao.ReimburseMapper;
import com.rs.model.CommonResult;
import com.rs.model.Project;
import com.rs.model.Reimburse;
import com.rs.service.rs.ReimburseService;

@Service
public class ReimburseServiceImpl implements ReimburseService {

	@Autowired
	private ReimburseMapper rm;

	//查询所有
	@Override
	public CommonResult<Map<String, Object>> reimburseAllPC(Reimburse reimburse) {

		Page<Reimburse> page = PageHelper.startPage(reimburse.getPageNum(), 10);//分页
		List<Project> list = rm.reimburseAllPC(reimburse);

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", list);
		map.put("total", page.getTotal());
		map.put("pages", page.getPages());
		map.put("pageNum", page.getPageNum());
		return new CommonResult<Map<String, Object>>(200, "查询成功", map);

	}

	//根据ID查询
	@Override
	public Reimburse reimburseByIdPC(Integer re_id) {
		return rm.reimburseByIdPC(re_id);
	}

	//添加申请
	@Override
	public int reimburseAddPC(Reimburse reimburse) {
		reimburse.setRe_audit(0);
		return rm.reimburseAddPC(reimburse);
	}

	//修改申请
	@Override
	public int reimburseUpdatePC(Reimburse reimburse) {

		return rm.reimburseUpdate(reimburse);
	}

	//删除申请
	@Override
	public int reimburseDel(Reimburse reimburse) {
		return rm.reimburseDel(reimburse);
	}

	//App查询所有
	@Override
	public List<Reimburse> reimburseAllApp() {
		return rm.reimburseAllApp();
	}

	//App添加申请
	@Override
	public int reimburseAddApp(Reimburse reimburse) {
		reimburse.setRe_audit(0);
		return rm.reimburseAddApp(reimburse);
	}

	//App修改申请
	@Override
	public int reimburseUpdateApp(Reimburse reimburse) {
		reimburse.setRe_audit(0);
		return rm.reimburseUpdateApp(reimburse);
	}

	//App删除申请
	@Override
	public int reimburseDelApp(Reimburse reimburse) {
		return rm.reimburseDelApp(reimburse);
	}

	//审核
	@Override
	public void reimburseToExamine(Reimburse reimburse) {
		// TODO Auto-generated method stub
		rm.reimburseUpdate(reimburse);
	}
}
